package cn.marinda.resturants.mapper;

import cn.marinda.resturants.entity.Member;
import cn.marinda.resturants.entity.Orders;
import cn.marinda.resturants.global.Pages;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.context.annotation.Primary;

import java.math.BigDecimal;

/** 会员mapper
 * @date 2021/11/16
 * @author Marinda
 *
 */
public interface MemberMapper extends BaseMapper<Member> {

    /** 查询指定会员的折扣
     *
     * @param uid uid
     * @return 折扣
     */
    @Select("select discount from r_member where uid = #{uid}")
    BigDecimal selectDiscount(Integer uid);

    /** 查询会员数量
     *
     * @param uid uid
     * @return 数量
     */
    @Select("select count from r_member where uid = #{uid}")
    Integer selectCount(Integer uid);

    /** 查询会员礼券数
     *
     * @param uid 会员uid
     * @return 礼券数
     */
    @Select("select vochers from r_member where uid = #{uid}")
    BigDecimal selectVochers(Integer uid);

    /** 查询会员名称
     *
     * @param uid uid
     * @return 会员名称
     */
    @Select("select name from r_member where uid = #{uid}")
    String selectName(Integer uid);

    /** 查询会员创建日期
     *
     * @param uid uid
     * @return 会员创建日期
     */

    @Select("select create_date from r_member where uid = #{uid}")
    String selectCreateDate(Integer uid);


    /** 分页
     *
     * @param pages 分页
     * @return 分页结果
     */
    @Select("select * from r_member ")
    IPage<Member> selectMemberPage(Pages<?> pages);
}
